package com.homesoft.runtime.metadata.modle;

import java.util.UUID;
import com.thoughtworks.xstream.annotations.XStreamAlias;


public class AbstractMetadataObject extends ValueChangeNotifier implements IMetadataObject, IListAware {
	
	private String name;

	private boolean isUserDefine;

	private boolean isInherited;

	private MultilingualField alias;

	private MultilingualField description;

	private ExtendDataList extData;

	protected AbstractMetadataObject() {
		this.name = "name_" + Math.abs(UUID.randomUUID().hashCode());
	}

	@Override
	public boolean isInherited() {
		return isInherited;
	}

	@Override
	public void setInherited(boolean inherited) {
		this.isInherited = inherited;
	}

	@Override
	public String getName() {
		return this.name;
	}

	@Override
	public void setName(String value) {
		if (name == value)
			return;
		String oldValue = name;
		if (NotifyEnabled()) {
			boolean cancel = this.OnPropertyChanging("Name", oldValue, value);
			if (cancel) {
				return;
			}
		}
		IOwnerAware owner = this.getOwner();
		IMetadataList list = null;
		if (owner instanceof IMetadataList) {
			list = (IMetadataList) this.getOwner();
		}
		if (list != null) {
			if (!list.ChangeItemKey(this, value)) {
				return;
			}
		}
		name = value;
		if (NotifyEnabled()) {
			OnPropertyChanged("Name", oldValue, value);
		}
	}

	@Override
	public MultilingualField getAlias() {
		return this.alias;
	}

	@Override
	public void setAlias(MultilingualField alias) {
		this.alias = (MultilingualField) alias;
	}

	@Override
	public MultilingualField getDescription() {
		return this.description;
	}

	@Override
	public void setDescription(MultilingualField description) {
		this.description = (MultilingualField) description;
	}

	@Override
	public boolean isUserDefine() {
		return this.isUserDefine;
	}

	@Override
	public void setUserDefine(boolean userDefine) {
		this.isUserDefine = userDefine;
	}

	@Override
	public IExtendDataList getExtData() {
		return this.extData;
	}

	@Override
	public void AfterLoad() {
	}
}
